<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>-->
    <!--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>-->
    <!--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>-->
    <!--[endif]-->
    <link rel="stylesheet" href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" />
    <link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.css" />
    <script type="text/javascript" src="../../common/js/public.js"></script>
    <script type="text/javascript" src="../../common/js/publicUtils.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=G3GKeZsowwfaOlY71VAd0TfR"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
    <style>
        .layui-input-inline,.buttondiv .layui-input-inline {
            float: left;
            /*width: 300px !important;*/
            margin-right: 10px;
        }
        .layui-form-item {
            margin-bottom: 8px !important;
        }
        .error{
            color: red;
            line-height: 20px;
        }
        .layui-form-label {
            padding: 9px 15px !important;
            width: 90px !important;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row" id="addpro">
        <form class="layui-form" lay-filter="formTest" id="formTest">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label"><span style="color: red;">*</span>项目名称</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input name="name" lay-verify="required" autocomplete="off" class="layui-input" type="text">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"><span style="color: red;">*</span>项目简称</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input name="shortName" lay-verify="required" autocomplete="off" class="layui-input" type="text">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">工程类别</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <select name="category" lay-verify="">

                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">项目状态</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <select name="state" lay-verify="">

                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">风险专业</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <select name="risk">

                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">工期等级</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <select name="durationGrade">

                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">合同造价</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input name="contractCost" autocomplete="off" class="layui-input" type="text">
                        <i class="layui-icon" style="position: absolute;top:5px;right: 8px;color:grey">万元</i>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">所属项目</label>
                    <div class="layui-input-inline" style="display: none">
                        <input id="prjId" name="prjId" hidden="hidden" autocomplete="off" class="layui-input" type="text">
                    </div>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="prjName" name="prjName" autocomplete="off" class="layui-input input_button" type="text" disabled="disabled">
                        <button type="button" class="btn_self layui-btn layui-btn-primary layui-btn-small button_input" style="border-radius: 2px;" onclick="getPro(event)">选择</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">建设单位</label>
                    <div class="layui-input-inline" style="display: none">
                        <input id="investedUnits" name="investedUnits" hidden="hidden" autocomplete="off" class="layui-input" type="text">
                    </div>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="investedUnitsName" name="investedUnitsName" autocomplete="off" class="layui-input input_button" type="text" disabled="disabled">
                        <button type="button" class="btn_self layui-btn layui-btn-primary layui-btn-small button_input" style="border-radius: 2px;" onclick="getResCom(event,'57-02 00 00','#investedUnitsName','#investedUnits')">选择</button>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">监理单位</label>
                    <div class="layui-input-inline" style="display: none">
                        <input id="supervisionUnits" name="supervisionUnits" hidden="hidden" autocomplete="off" class="layui-input" type="text">
                    </div>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="supervisionUnitsName" name="supervisionUnitsName" autocomplete="off" class="layui-input input_button" type="text" disabled="disabled">
                        <button type="button" class="btn_self layui-btn layui-btn-primary layui-btn-small button_input" style="border-radius: 2px;" onclick="getResCom(event,'57-10 00 00','#supervisionUnitsName','#supervisionUnits')">选择</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">起点里程</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input name="beginMileage" autocomplete="off" class="layui-input" type="text">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">终点里程</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input name="endMileage" autocomplete="off" class="layui-input" type="text">
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">排&emsp;&emsp;序</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input name="sort" autocomplete="off" class="layui-input" type="text">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">GPS坐标</label>
                    <div class="layui-input-inline" style="position: relative;width:400px;">
                        <input name="gps" id="gpsInput" autocomplete="off" placeholder="" class="layui-input input_button" type="text">
                        <button type="button" class="btn_self layui-btn layui-btn-primary layui-btn-small button_input" onclick="getGps()" style="border-radius: 2px;">选择</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">公司分管领导</label>
                    <div class="layui-input-inline" style="display: none">
                        <input id="companyLeader" name="companyLeader" hidden="hidden" autocomplete="off" class="layui-input" type="text">
                    </div>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="companyLeaderName" name="companyLeaderName" autocomplete="off" class="layui-input input_button" type="text" disabled="disabled">
                        <button type="button" class="btn_self layui-btn layui-btn-primary layui-btn-small button_input" style="border-radius: 2px;" onclick="selectForLeader(event,'#companyLeader','#companyLeaderName','公司分管领导')">选择</button>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">局分管领导</label>
                    <div class="layui-input-inline" style="display: none">
                        <input id="groupLeader" name="groupLeader" hidden="hidden" autocomplete="off" class="layui-input input_button" type="text">
                    </div>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="groupLeaderName" name="groupLeaderName" autocomplete="off" class="layui-input input_button" type="text" disabled="disabled">
                        <button type="button" class="btn_self layui-btn layui-btn-primary layui-btn-small button_input" style="border-radius: 2px;" onclick="selectForLeader(event,'#groupLeader','#groupLeaderName','局分管领导')">选择</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" pane="">
                    <label class="layui-form-label">重难点工程</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="tunnel" id="tunnel" lay-skin="primary" title="隧道工程" value="1">
                        <input type="checkbox" name="subway" id="subway" lay-skin="primary" title="地铁及地下工程" value="1">
                        <input type="checkbox" name="bridge" id="bridge" lay-skin="primary" title="高难度桥梁工程" value="1">
                        <input type="checkbox" name="operatingLine" id="operatingLine" lay-skin="primary" title="营业线及其他重难点工程" value="1">
                    </div>
            </div>

            <!--<div class="layui-form-item">-->
                <!--<div class="layui-inline">-->
                    <!--<label class="layui-form-label">详细地址</label>-->
                    <!--<div class="layui-input-inline"  style="width:235px;">-->
                        <!--<select id="address_province" lay-filter="province">-->
                        <!--</select>-->
                    <!--</div>-->
                    <!--<div class="layui-input-inline" style="width:235px;">-->
                        <!--<select id="address_city" lay-filter="city">-->
                        <!--</select>-->
                    <!--</div>-->
                    <!--<div class="layui-input-inline" style="width:235px;">-->
                        <!--<select id="address_zone" lay-filter="zone">-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->
                <!--<br/>-->
                <!--<div class="layui-inline">-->
                    <!--<label class="layui-form-label"></label>-->
                    <!--<div class="layui-input-inline" style="width:725px;"><input id="address_info" class="layui-input"/></div>-->
                <!--</div>-->

            <!--</div>-->
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">开工日期</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="beginDate" name="beginDate" class="layui-input" >
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">竣工日期</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <input id="endDate" name="endDate" class="layui-input" >
                    </div>
                </div>
            </div>
            <div class="layui-form-item  layui-form-text">
                    <label class="layui-form-label">项目概况</label>
                    <div class="layui-input-block" style="width:935px;margin-left: 120px;">
                        <textarea name = "profile" id="profile" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
            </div>
        </form>
    </div>
</div>
<div id='gpsmap' style="display: none;height: 100%;">
    <div id="allmap" style="overflow:hidden;zoom:1;position:relative;width: 100%; height:100%;">
        <div id="map" style="height:100%;-webkit-transition: all 0.5s ease-in-out;transition: all 0.5s ease-in-out;"></div>
    </div>
</div>
<div id='pro' style="display: none;padding-top:15px">
    <div class="layui-inline">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-inline">
            <input type="text" id="name" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <button class="layui-btn" onclick="searchData()">查询</button>
        </div>
    </div>
    <table class="layui-hide" id="proTable"></table>
</div>

<div id='com' style="display: none;">
    <table class="layui-hide" id="comTable"></table>
</div>
</body>
<script>
    var node,form,laydate,layer,upload,provinceStr,cityStr,zoneStr,flag=1,table,nodeForUpdate,projectStates,companyTypeMap;
    var mk,overlays_one = [],overlays = [],map;
    $(function(){
        node = window.parent.nodeSelected;
        //initProvincePick();
        layui.use(['form','laydate','layer','upload'], function(){
            form = layui.form;
            laydate = layui.laydate;
            layer = layui.layer;
            upload = layui.upload;
            table = layui.table;
            //var orgId = node.id;

            // 执行实例

            select = layui.select;

            //执行一个laydate实例
            laydate.render({
                elem: '#beginDate' //指定元素
                ,value: new Date()
            });
            laydate.render({
                elem: '#endDate' //指定元素
                ,value: new Date()
            });

            // form.on('select(province)', function(data){
            //     provinceStr = data.elem[data.elem.selectedIndex].text;
            //     initPick(data.value,'#address_city','');
            // });
            // form.on('select(city)', function(data){
            //     cityStr = data.elem[data.elem.selectedIndex].text;
            //     initPick(data.value,'#address_zone','');
            // });
            // form.on('select(zone)', function(data){
            //     zoneStr = data.elem[data.elem.selectedIndex].text;
            // });
            /*        form.on('select(province)', function(data){
                        initCityPick(data.value);
                    });*/
    })
        companyTypeMap=getDic("CompanyType");
 })

//初始化下拉框
function initJobSelect(){
   //初始化工程类别
    publicAjax(null,'infDisciplines/queryInfDisciplinesList',{'type':1},false,null,function (data){
        if(data.code == 2000){
            var selectStr = '';
            var json= data.data;
            for(var i=0;i<json.length;i++){
                selectStr = selectStr + "<option value='"+json[i].id+"'>"+json[i].name+"</option>";
            }
            $("select[name='category']").html('');
            $("select[name='category']").html(selectStr);

        }
    });


    //初始化项目状态
    publicAjax(null,'infdictitem/selectInfdictitemByInfdictsortCode',{'code':'PrjState'},false,null,function (data){
        if(data.code == 2000){
            var selectStr = '';
            var json= data.data;
            projectStates = json;
            console.log(projectStates);
            for(var i=0;i<json.length;i++){
                selectStr = selectStr + "<option value='"+json[i].code+"'>"+json[i].name+"</option>";
            }
            $("select[name='state']").html('');
            $("select[name='state']").html(selectStr);

        }
    });
    //初始化风险专业
    publicAjax(null,'infdictitem/selectInfdictitemByInfdictsortCode',{'code':'PrjRiskPro'},false,null,function (data){
        if(data.code == 2000){
            var selectStr = '';
            var json= data.data;
            for(var i=0;i<json.length;i++){
                selectStr = selectStr + "<option value='"+json[i].code+"'>"+json[i].name+"</option>";
            }
            $("select[name='risk']").html('');
            $("select[name='risk']").html(selectStr);

        }
    });
    //初始化工期状态等级
    publicAjax(null,'infdictitem/selectInfdictitemByInfdictsortCode',{'code':'PrjPeriodLevel'},false,null,function (data){
        if(data.code == 2000){
            var selectStr = '';
            var json= data.data;
            for(var i=0;i<json.length;i++){
                selectStr = selectStr + "<option value='"+json[i].code+"'>"+json[i].name+"</option>";
            }
            $("select[name='durationGrade']").html('');
            $("select[name='durationGrade']").html(selectStr);

        }
    });
    form.render();
}

    //初始化省市联动
    function initProvincePick(){
        $.ajax({
            type : 'GET',//请求类型
            url : 'http://apis.map.qq.com/ws/district/v1/list?key=JU2BZ-PYSCD-KQZ46-HLBF6-N2IA5-JQBIF&output=jsonp&callback=?',//请求地址，这里的key参数需要自行注册获取应用key，注册地址（http://lbs.qq.com/webservice_v1/guide-region.html）
            data : '',//请求数据，String型
            async : false,//是否为异步
            cache : false,//是否缓存
            dataType:'jsonp',//指定jsonp类型
            success : function(data){
                var provinces = data['result'][0];
                var provinceHtml = "<option value=''>请选择</option>";
                $.each(provinces, function(idx, obj) {
                    provinceHtml += "<option value="+obj.id+">"+obj.fullname+"</option>";
                });
                $('#address_province').html("");
                $('#address_province').append(provinceHtml);
                form.render('select');
            }
        });
    }
    //根据省获取市
    function initPick(provinceId,id,idSelected){
        if(typeof (idSelected) === 'undefined'){
            idSelected = '';
        }
        if(typeof(provinceId) !== 'undefined' && provinceId !== ''){
            $.ajax({
                type : 'GET',//请求类型
                url : 'http://apis.map.qq.com/ws/district/v1/getchildren?key=JU2BZ-PYSCD-KQZ46-HLBF6-N2IA5-JQBIF&id='+provinceId+'&output=jsonp&callback=?',//请求地址，这里的key参数需要自行注册获取应用key，注册地址（http://lbs.qq.com/webservice_v1/guide-region.html）
                data : '',//请求数据，String型
                async : false,//是否为异步
                cache : false,//是否缓存
                dataType:'jsonp',//指定jsonp类型
                success : function(data){
                    var city = data['result'][0];
                    var cityHtml = "<option value=''>请选择</option>";
                    $.each(city, function(idx, obj) {
                        if(obj.id === idSelected){
                            cityHtml += "<option value="+obj.id+" selected='selected'>"+obj.fullname+"</option>";
                        }else{
                            cityHtml += "<option value="+obj.id+">"+obj.fullname+"</option>";
                        }
                    });
                    $(id).html("");
                    $(id).append(cityHtml);
                    form.render('select');
                }
            });
        }
    }

    //弹出页面选择所属项目
    function getPro() {
        var e = document.all ? window.event : arguments[0] ? arguments[0] : event ;
        e.stopPropagation();
        e.preventDefault();
        var index = layer.open({
            type: 1,
            title: '选择所属项目',
            maxmin: false,
            shadeClose: false, //点击遮罩关闭层
            area: ['900px', '500px'],
            content: $("#pro"),
            btn: ['确定'],
            success: function() {
                initTableForSelect();
            },
            yes: function(index, layero) {
                var nodeSelected = table.checkStatus('proTable').data;
                if(typeof(nodeSelected) !== 'undefined' && nodeSelected !== null){
                    if(nodeSelected.length === 1){
                        $('#prjName').val(nodeSelected[0].name);
                        $('#prjId').val(nodeSelected[0].id);
                        layer.close(index);
                    }else{
                        layer.alert('只能选择一个父项目');
                    }
                }else{
                    layer.alert("请选择项目");
                }
            },
            cancel: function(index, layero) {

            }
        });
    }

    var typeGlo;

    //弹出页面选择所属建设单位和监理单位
    function getResCom(event,type,name,id) {
        var title="选择项目";
        if(type=='57-02 00 00'){
            title = '选择建设单位';
        }else if(type=='57-10 00 00'){
            title = '选择监理单位';
        }
        typeGlo = type;
        var e = document.all ? window.event : arguments[0] ? arguments[0] : event ;
        e.stopPropagation();
        e.preventDefault();
        var index = layer.open({
            type: 2,
            title: title,
            maxmin: false,
            shadeClose: false, //点击遮罩关闭层
            area: ['900px', '500px'],
            content: 'rescom.html',
            btn: ['确定'],
            yes: function(index, layero) {
                var nodeSelected = window[layero.find('iframe')[0]['name']].table.checkStatus('datatable').data;
                if(typeof(nodeSelected) !== 'undefined' && nodeSelected !== null){
                    if(nodeSelected.length === 1){
                        $(name).val(nodeSelected[0].name);
                        $(id).val(nodeSelected[0].id);
                        layer.close(index);
                    }else{
                        layer.alert('只能选择一个父项目');
                    }
                }else{
                    layer.alert("请选择项目");
                }
            },
            cancel: function(index, layero) {

            }
        });
    }

    //获取所有项目用于选择父项目
    function initTableForSelect(){
        var cols = [
            [   {
                type:'checkbox',
                },
                {
                    type: 'numbers',
                    title: '序号',
                    align: 'center',
                }, {
                field: 'name',
                title: '名称',
                sort: true,
                width: "25%",
                align: 'center'
            }, {
                field: 'shortName',
                title: '简称',
                sort: true,
                width: "20%",
                align: 'center',
            }, {
                field: 'state',
                title: '状态',
                templet: function(d) {
                    var value = "在建";
                    for(var i=0;i<projectStates.length;i++){
                        if(projectStates[i].code == d.state){
                            value = projectStates[i].name;
                            break;
                        }
                    }
                    return value;
                },
                width: "10%",
                sort: false,
                align: 'center'
            }/*,{
                field: 'contractCost',
                title: '合同造价',
                sort: true,
                width: "10%",
                align: 'center'
            }*/,{
                field: 'beginDate',
                title: '合同开工日期',
                sort: false,
                width: "14%",
                align: 'center'
            },{
                field: 'endDate',
                title: '合同完工日期',
                sort: false,
                width: "14%",
                align: 'center'
            }]
        ]
        layui.use('table', function() {
            table = layui.table;
            table.render({
                elem: '#proTable',
                size:"sm",
                height: 'full-300',
                headers: {"Authorization":getData("Authorization")},
                url:'/mdm/project/getAllProjects',
                where: {"name":$("#name").val()},
                parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };
                },
                response: {
                    statusCode: 2000,
                },
                method: 'post',
                cols: cols,
                limit: 20,
                page: true
                /*  page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                      layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'] //自定义分页布局
                  },*/
                /*done: function(){
                    store.get('loginName') != 'Administrator' ? $('img[lay-event="delet"]').addClass('hideNone') : $('img[lay-event="delet"]').removeClass('hideNone')
                }*/
            });
        })
    }

    function searchData(){
        initTableForSelect();
    }
    /* *
     * @Author bxf
     * @Description 初始化更新
     * @Date 8:42 2019/9/4
     * @param null
     * @return
     */
    function inintflag(val,data){//val：1为新增2未标记
        initJobSelect();
        if(val==2){
            flag = 2;
            nodeForUpdate = data;
            $("form[id='formTest'] :input").removeAttr("disabled");
            $('#prjName').attr("disabled",true);
            layui.use('form',function(){
                var form= layui.form;
                form.val("formTest", {
                    name: nodeForUpdate[0].name,
                    shortName: nodeForUpdate[0].shortName,
                    code:nodeForUpdate[0].code,
                    state:nodeForUpdate[0].state,
                    risk:nodeForUpdate[0].risk,
                    durationGrade:nodeForUpdate[0].durationGrade,
                    companyLeader:nodeForUpdate[0].companyLeader,
                    groupLeader:nodeForUpdate[0].groupLeader,
                    category:nodeForUpdate[0].category,
                    contractCost:nodeForUpdate[0].contractCost,
                    investedUnits:nodeForUpdate[0].investedUnits,
                    supervisionUnits:nodeForUpdate[0].supervisionUnits,
                    investedUnitsName:nodeForUpdate[0].investedUnitsName,
                    supervisionUnitsName:nodeForUpdate[0].supervisionUnitsName,
                    beginMileage:nodeForUpdate[0].beginMileage,
                    endMileage:nodeForUpdate[0].endMileage,
                    prjName:nodeForUpdate[0].orgName,
                    orgId:nodeForUpdate[0].orgId,
                    prjId:nodeForUpdate[0].prjId,
                    gps:nodeForUpdate[0].gps,
                    tenders:nodeForUpdate[0].tenders,
                    grade:nodeForUpdate[0].grade,
                    standard:nodeForUpdate[0].standard,
                    properties:nodeForUpdate[0].properties,
                    //address:nodeForUpdate[0].address,
                    sort:nodeForUpdate[0].sort,
                    profile:nodeForUpdate[0].profile,
                    beginDate:nodeForUpdate[0].beginDate,
                    endDate:nodeForUpdate[0].endDate
                });
                var addressStr = nodeForUpdate[0].address;
                // if(typeof(addressStr) !== 'undefined' && addressStr !== ''){
                //     var addressList = addressStr.split("@");
                //     $("#address_province").find("option[value='"+addressList[0]+"']").prop("selected",true);
                //     initPick(addressList[0],'#address_city',addressList[1]);
                //     initPick(addressList[1],'#address_zone',addressList[2]);
                //     $("#address_info").val(addressList[3]);
                // }
                if(nodeForUpdate[0].subway === '1'){
                    $("#subway").attr("checked", "checked");
                }
                if(nodeForUpdate[0].bridge === '1'){
                    $("#bridge").attr("checked", "checked");
                }
                if(nodeForUpdate[0].operatingLine === '1'){
                    $("#operatingLine").attr("checked", "checked");
                }
                if(nodeForUpdate[0].tunnel === '1'){
                    $("#tunnel").attr("checked", "checked");
                }
                $('#profile').val(nodeForUpdate[0].profile);
                form.render();
            })
        }
    }

    //选择部门领导
    function selectForLeader(event,id,name,title){
      //  var data = obj.data[0]; //idTest 即为基础参数 id 对应的值
        var e = document.all ? window.event : arguments[0] ? arguments[0] : event ;
        e.stopPropagation();
        e.preventDefault();
        layer.open({
            type: 2,
            area: ["900px" , "500px"],
            fix: false,
            //不固定
            maxmin: false,
            shade: 0.3,
            title: title,
            content: "bindperson.html",
            btn: ['确定'],
            // 弹层外区域关闭
            shadeClose: false,
            yes: function(index,layero){
                var nodeSelected = window[layero.find('iframe')[0]['name']].table.checkStatus('datatable').data;
                if(typeof(nodeSelected) !== 'undefined' && nodeSelected !== null){
                    if(nodeSelected.length === 1){
                        $(name).val(nodeSelected[0].name);
                        $(id).val(nodeSelected[0].id);
                        layer.close(index);
                    }else{
                        layer.alert('只能选择一个父项目');
                    }
                }else{
                    layer.alert("请选择项目");
                }
            },
            cancel: function(index) {
                return true;
            }
        });
    }

    /* *
     * @Author bxf
     * @Description 更新
     * @Date 8:04 2019/9/4
     * @param null
     * @return
     */
    function submitupdate(url) {
        if(!$("#addpro input[name='name']").val().replace(/^ +| +$/g,'')) {
            layer.msg('请输入项目名称！', {
                time: 1000
            });
            return;
        }
        if(!$("#addpro input[name='shortName']").val().replace(/^ +| +$/g,'')) {
            layer.msg('请输入项目简称！', {
                time: 1000
            });
            return;
        }
        if($("#addpro input[name='startDate']").val() && $("#addpro input[name='endDate']").val() && ($("#addpro input[name='startDate']").val().replace(/-/g,'') > $("#addpro input[name='endDate']").val().replace(/-/g,'') || $("#addpro input[name='startDate']").val().replace(/-/g,'') == $("#addpro input[name='endDate']").val().replace(/-/g,''))) {
            layer.msg('开工日期应小于竣工日期！', {
                time: 1000
            });
            return;
        }
        var data = $('#formTest').serializeJson();
        // var urls = 'projectManage/' + url;

        data.orgId = nodeForUpdate[0].orgId;
        data.prjId = $('#prjId').val();
        data.id = nodeForUpdate[0].id;
        //data.address = $('#address_province').val()+"@"+$('#address_city').val()+"@"+$('#address_zone').val()+"@"+$('#address_info').val();
        //data.gps = $('#gpsInput').val();
        publicAjax(null,url,data,false,null,function(data){
            if(data.code == 2000){
                laysuccess("更新成功！");
                delayLoad(function(){
                    parent.layer.close(window.parent.index_i);
                    window.parent.zTreeObj.reAsyncChildNodes(window.parent.nodeSelected, "refresh");
                    var data = {"companyId":node.id};
                    window.parent.reloadTable("datatable",data);
                })
            }else{
                layself(data.msg);
            }
        })
    }
    /* *
     * @Author bxf
     * @Description 创建新增
     * @Date 8:05 2019/9/4
     * @param null
     * @return 
     */
    function submitcreate(url) {
        if(!$("#addpro input[name='name']").val().replace(/^ +| +$/g,'')) {
            layer.msg('请输入全称！', {
                time: 1000
            });
            return;
        }

        if(!$("#addpro input[name='shortName']").val().replace(/^ +| +$/g,'')) {
            layer.msg('请输入简称！', {
                time: 1000
            });
            return;
        }
        var data = $('#formTest').serializeJson();
        data.orgId = node.id;
        // var province = $('#address_province').val()!==null?$('#address_province').val():"";
        // var city = $('#address_city').val()!==null?$('#address_city').val():"";
        // var zone = $('#address_zone').val()!==null?$('#address_zone').val():"";
        // data.address = province+"@"+city+"@"+zone+"@"+$("#address_info").val();
        //data.pId = parentId ? parentId : 0;
        publicAjax(null,url,data,null,null,function (r){
            if(r.code == 2000){
                laysuccess("保存成功！");
                delayLoad(function(){
                    parent.layer.close(window.parent.index_i1);
                    window.parent.zTreeObj.reAsyncChildNodes(window.parent.nodeSelected, "refresh");
                    var data = {"companyId":node.id};
                    window.parent.reloadTable("datatable",data);
                })
                /* if(index_i1) {

                 }else{
                     $("#formTest select[name='state']").val(1)
                     form.render("select");
                 }*/
            }else{
                layself(r.msg);
            }
        })
    }

    /**
     * 打开地图按钮
     */
    function getGps() {
        var e = document.all ? window.event : arguments[0] ? arguments[0] : event ;
        e.stopPropagation();
        e.preventDefault();
        var index = layer.open({
            type: 1,
            title: '选择GPS',
            maxmin: true,
            shadeClose: false, //点击遮罩关闭层
            area: ['750px', '480px'],
            content: $("#gpsmap"),
            btn: ['确定'],
            success: function() {
                $('.layui-layer-btn .layui-layer-btn0').css({
                    'border-color': '#1E9FFF ',
                    'background-color': '#1E9FFF'
                })
                // 百度地图API功能
                map = new BMap.Map('map');
                if(flag==1){
                    var poi = new BMap.Point(117.227737,31.828551);
                }else{
                    if($("#gps").val()){
                        var arr=$("#gps").val().split(',')
                        var poi = new BMap.Point(arr[0],arr[1]);
                    }else{
                        var poi = new BMap.Point(117.227737,31.828551);
                    }
                }
                map.centerAndZoom(poi, 10);
                mk = new BMap.Marker(poi);//创建标注图标
                overlays_one.push(mk);
                map.addOverlay(mk);//将标注添加到地图中
                map.enableScrollWheelZoom();
                var overlaycomplete = function(e) {
                    overlays_one = [];
                    overlays_one.push(e.overlay);
                    overlays.push(e.overlay);
                };
                var styleOptions = {
                    strokeColor: "red", //边线颜色。
                    fillColor: "red", //填充颜色。当参数为空时，圆形将没有填充效果。
                    strokeWeight: 3, //边线的宽度，以像素为单位。
                    strokeOpacity: 0.8, //边线透明度，取值范围0 - 1。
                    fillOpacity: 0.6, //填充的透明度，取值范围0 - 1。
                    strokeStyle: 'solid' //边线的样式，solid或dashed。
                }
                //实例化鼠标绘制工具
                var drawingManager = new BMapLib.DrawingManager(map, {
                    isOpen: false, //是否开启绘制模式
                    enableDrawingTool: true, //是否显示工具栏
                    drawingToolOptions: {
                        anchor: BMAP_ANCHOR_TOP_RIGHT, //位置
                        offset: new BMap.Size(5, 5), //偏离值
                        scale: 0.8, //工具栏缩放比例
                        drawingModes: [BMAP_DRAWING_MARKER]
                    },
                    circleOptions: styleOptions, //圆的样式
                    polylineOptions: styleOptions, //线的样式
                    polygonOptions: styleOptions, //多边形的样式
                    rectangleOptions: styleOptions //矩形的样式
                });
                var timer, count = 0;
                map.addEventListener("click", function(e) {
                    clearAll();
//							count++;
//							timer = window.setTimeout(function() {
//								if(count == 1) {
//									console.log(e.point.lng + '|' + e.point.lat );
//								}
//								window.clearTimeout(timer);
//								count = 0;
//							}, 300)
                });
                drawingManager.addEventListener('overlaycomplete', overlaycomplete);
            },
            yes: function(index, layero) {
                $('.layui-layer-btn .layui-layer-btn0').css({
                    'border-color': '#FFC107',
                    'background-color': '#FFC107'
                })
                $("#gpsInput").val(overlays_one[0].point.lng + ',' + overlays_one[0].point.lat);
                layer.close(index);
            },
            cancel: function(index, layero) {
                $('.layui-layer-btn .layui-layer-btn0').css({
                    'border-color': '#FFC107',
                    'background-color': '#FFC107'
                })
            }
        });
    }
    function clearAll() {
        if(mk) map.removeOverlay(mk);
        if(overlays.length > 1) {
            for(var i = 0; i < overlays.length; i++) {
                if(i != overlays.length - 1) {
                    map.removeOverlay(overlays[i]);
                }
            }
        }
    }
</script>
</html>